package com.course.service.impl;

import com.course.entity.ResultBody;
import com.course.mapper.MessageMapper;
import com.course.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class MessageServiceImpl implements MessageService {

    @Autowired
    private MessageMapper messageMapper;


//    @Override
//    public ResultBody getusercourse(Map<String, Object> map) {
//
//        return new ResultBody(200, "查询成功", messageMapper.getusercourse(map));
//    }

    @Override
    public ResultBody getteachercourse(Map<String, Object> map) {
        return new ResultBody(200, "查询成功", messageMapper.getteachercourse(map));
    }
//学生向老师发信息
    @Override
    public ResultBody  sendmessage(Integer messagenumber,Integer messagecourse,String messagetext,String messagetype)
    {
        if(messageMapper.sendmessage(messagenumber,messagecourse,messagetext,messagetype)>0)
        {
            return new ResultBody(200,"发送信息成功",true);
        }
        else
            return new ResultBody(400,"发送信息失败",false);
    }
//展示学生所发送的信息
    @Override
    public ResultBody displaysmessage(Integer messagecourse)
    {
        List<Map<String,Object>>map=messageMapper.displaysmessage(messagecourse);
        if(map!=null)
        {
            return new ResultBody(200,"展示学生发送信息成功",map,map.size());
        }
        else
            return new ResultBody(400,"展示学生发送信息失败",false);
    }

//    @Override
//    public ResultBody displaymessagem(Integer messagecourse,Integer messagenumber)
//    {
//        List<Map<String,Object>>map=messageMapper.displaymessagem(messagecourse,messagenumber);
//        if(map!=null)
//        {
//            return new ResultBody(200,"展示详细信息正确",map,map.size());
//        }
//        else
//            return new ResultBody(400,"展示详细信息失败",false);
//    }

}
